<template>
    <div>
        <!-- 顶部滚动区域 -->
        <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll">
						<a class="mui-control-item mui-active" href="#item1mobile" data-wid="tab-top-subpage-1.html">
							全部
						</a>
						<a class="mui-control-item" href="#item2mobile" data-wid="tab-top-subpage-2.html">
							热点
						</a>
						<a class="mui-control-item" href="#item3mobile" data-wid="tab-top-subpage-3.html">
							北京
						</a>
						<a class="mui-control-item" href="#item4mobile" data-wid="tab-top-subpage-4.html">
							社会
						</a>
						<a class="mui-control-item" href="#item5mobile" data-wid="tab-top-subpage-5.html">
							娱乐
						</a>
						<a class="mui-control-item" href="#item6mobile" data-wid="tab-top-subpage-6.html">
							科技
						</a>
					</div>
				</div>

			</div>
            <!-- 顶部滚动区域渲染版 -->
            <!-- <div id="slider" class="mui-slider">
				<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
					<div class="mui-scroll" >
						<a :class="['mui-control-item', item.id==0? 'mui-active': '']" v-for="item in cates" :key="item.id" @tap="getPhotoListByCateId(item.id)">
							{{item.title}}
						</a>
						
					</div>
				</div>

			</div> -->
             <!-- 图片列表数据样式版    -->

            <ul class="photo-list">
                <router-link to="/home/photoinfo/13" tag="li">
                    <img src="../../images/1.jpg">
                    <div class="info">
                        <div class="info-tltle">
                            ewqeqweeeeeeeeqweeeeeeeeeeeeeeeeeeeeeee
                        </div>
                        <div class="info-content">
                            的人纷纷个人股
                        </div>
                    </div>
                </router-link>
                 <router-link to="/home/photoinfo/14" tag="li">
                    <img src="../../images/1.jpg">
                    <div class="info">
                        <div class="info-tltle">
                            ewqeqweeeeeeeeqweeeeeeeeeeeeeeeeeeeeeee
                        </div>
                        <div class="info-content">
                            的人纷纷个人股
                        </div>
                    </div>
                </router-link>
            </ul>

              <!-- 图片列表数据渲染版    -->
            <!-- <ul class="photo-list">
                <router-link :to="'/home/photoinfo'+item.id" v-for="item in list" :key="item.id" tag="li">
                    <img v-lazy="item.img_url">
                    <div class="info">
                        <div class="info-tltle">
                            {{ item.title }}
                        </div>
                        <div class="info-content">
                            {{ item.zhaiyao }}    
                        </div>
                    </div>
                </router-link>
            </ul> -->


    </div>
</template>

<script>
       //导入mui的js文件,解决初始化scroll控件
       import mui from "../../lib/mui/js/mui.min.js" 

        

        export default {
            data(){
                return {
                    cates: [],  //图片分类数据
                    list: []    //图片列表
                }
            },
            created(){
                //this.getAllCategory(),
                // 默认进入页面，就主动请求 所有图片列表的数据
                //this.getPhotoListByCateId(0);
            },
            methods: {
                //获得图片分类数据
                getAllCategory(){
                    this.$http.get("api/getimgcategory").then(result=>{
                        if(result.body.status === 0 ){
                            result.body.message.unshift({titie: "全部",id: 0})
                            this.cates = result.body.message
                        }
                    })
                },
                //根据图片分类id得到对应的图片列表
                getPhotoListByCateId(cateId){
                    this.$http.get("api/getimages/"+cateId).then(result=>{
                        if(result.body.status == 0){
                            this.list = result.body.message;
                        }
                    })
                }

            },
            mounted () {
                        //因为只有DOM加载完毕后才能获取到滚动元素
                        mui('.mui-scroll-wrapper').scroll({
                    deceleration: 0.0005 //flick 减速系数，系数越大，滚动速度越慢，滚动距离越小，默认值0.0006
                });
            }
        }

</script>

<style lang="scss" scoped>
    /*去除滚动时的报错效果*/
    * {
    touch-action: pan-y;
    }


    .photo-list {
        padding: 10px;
        margin: 0;
        list-style: none;
        padding-bottom: 0;
        li {
            /*背景是让懒加载实现能看到*/
            background-color: #ccc;
            position: relative;
            box-shadow: 0 0 9px #999;
            text-align: center;
            margin-bottom: 10px;

            img {
                width: 100%;
                vertical-align: middle;
            }
            img[lazy="loading"] {
                width: 40px;
                height: 300px;
                margin: auto;
                }
            .info {
                color: white;
                position: absolute;
                bottom: 0;
                background-color: rgba(0,0,0,0.4);
                text-align: left;
                max-height: 84px;
                .info-title {
                    font-size: 14px;
                    font-weight: blod;
                    
                    
                }
                .info-content {
                    font-size: 13px;

                }
            }
        }
    }



</style>